package com.bbs.feign;

import com.bbs.pojo.Message;
import com.bbs.pojo.Result;
import com.bbs.pojo.UserPrincipal;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@FeignClient("message-service")
public interface MessageClient {
    /**
     * MessageDto无法被直接反序列化
     * 将MessageDto反序列化为LinkedHashMap
     */
    @GetMapping("/api/sys/messages/{id}")
    Result<Object> getMessage(@PathVariable("id") String id);

    @DeleteMapping("/api/sys/messages/{id}")
    Result<Object> removeMessage(@PathVariable("id") String id);

    /**
     * 条件消息
     */
    @GetMapping("/api/sys/messages/search")
    public Result<List<Message>> getMessages(@RequestBody Message message);
}
